package org.zfes.snowier.cloud.zbss.cms.router.service.site;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.site.model.CmsSite;
import org.zfes.snowier.cloud.zbss.cms.site.service.ICmsSiteService;
@Controller 
@RequestMapping("/cms/site/cmsSite")
public class CmsSiteController extends BaseController {

	
	@Autowired
	private ICmsSiteService cmsSiteService;
	
	@RequiresPermissions(value="cmsSite:loadCmsSiteDataSet",desc="站点列表")
    @RequestMapping(value="/loadCmsSiteDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsSiteDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsSiteService.loadCmsSiteDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsSite:createCmsSite",desc="站点添加")
    @RequestMapping(value="/createCmsSite", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsSite(CmsSite cmsSite){
		cmsSiteService.createCmsSite(cmsSite);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsSite:loadCmsSite",desc="站点加载")
    @RequestMapping(value="/loadCmsSite", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsSite(Long id){
		Optional<CmsSite> ops = cmsSiteService.loadCmsSiteById(id);
		return ajaxQuery("cmsSite",ops);
    }
	
	@RequiresPermissions(value="cmsSite:updateCmsSite",desc="站点更新")
    @RequestMapping(value="/updateCmsSite", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsSite(CmsSite cmsSite){
		cmsSiteService.updateCmsSite(cmsSite);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsSite:deletCmsSite",desc="站点删除")
    @RequestMapping(value="/deleteCmsSite", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsSite(Long id){
		cmsSiteService.deleteCmsSite(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}